package com.lei.design.singleton;

import java.util.Objects;

/**
 * @Author LeiXiaoLei
 * @Date 2022/5/20 09:28
 * @Version 1.0
 */
public class Singleton {
    // 在静态初始化器中创建的单例，这段代码保证了线程安全
    //private static Singleton uniqueInstance = new Singleton();
    private static Singleton uniqueInstance;
    private Singleton() {
    }

    public static Singleton getInstance() {
        if (Objects.isNull(uniqueInstance)) {
            uniqueInstance = new Singleton();
        }
        return uniqueInstance;
    }
}
